package com.example.demo.controller;


import com.example.demo.model.common.DeviceRenewalRequest;
import com.example.demo.model.common.DeviceRenewalResponse;
import com.example.demo.service.DeviceRenewalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/device")
public class DeviceRenewalController {

    @Autowired
    private DeviceRenewalService deviceRenewalService;

    @PostMapping("/renewal")
    public ResponseEntity<DeviceRenewalResponse> renewDevice(@RequestBody DeviceRenewalRequest request) {
        // 输出请求参数
        System.out.println("收到设备续费请求: " + request);
        DeviceRenewalResponse response = deviceRenewalService.processRenewal(request);
        return ResponseEntity.ok(response);
    }
}